#include <iostream>
#include <stdio.h>

#include "pthread.h"

typedef struct ThreadParam
{
    int id;
}ThreadParam;


__thread int x;

void* ThreadFunction(void* arg)
{
    ThreadParam *param = (ThreadParam*)arg;
    x = pthread_self();
    printf("id %d: x=%d\n", param->id, x);
    return NULL;
}

int main()
{
    pthread_t t1, t2;
    ThreadParam param1,param2;
    param1.id = 1;
    param2.id = 2;

    x = 10086;

    pthread_create(&t1, NULL, ThreadFunction, (void*)&param1);
    pthread_create(&t2, NULL, ThreadFunction, (void*)&param2);
    pthread_join(t1, NULL);
    pthread_join(t2, NULL);

    printf(" x=%d\n", x);
    return 0;
}